import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig>;

  // override config from framework / plugin
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1626060121032_3600';


  // add your egg config in here
  config.middleware = [];

  config.cluster = {
    listen: {
      port: 8000,
      hostname: '127.0.0.1',
    },
  };

  config.multipart = {
    mode: 'file',
  };

  config.security = {
    // 关闭 csrf
    csrf: {
      enable: false,
    },
    domainWhiteList: [
      'http://47.96.132.165:3000',
      'http://localhost:3500' ],
  };

  config.mysql = {
    // 单数据库信息配置
    client: {
      // host
      host: 'rm-bp1124zoclat0voo6yo.mysql.rds.aliyuncs.com',
      // 端口号
      port: '3306',
      // 用户名
      user: 'chenfeng_7xhome',
      // 密码
      password: 'Cf2925631',
      // 数据库名
      database: '7xhome',
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };

  // add your special config in here
  const bizConfig = {
    sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,
    jwt: {
      secret: 'cf2925631',
    },
  };

  // the return config will combines to EggAppConfig
  return {
    ...config,
    ...bizConfig,
  };
};
